package com.ymatou.iapi.sellerquery.service;

import java.util.ArrayList;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.sellerquery.parameter.resp.CreditInfoListResp;
import com.ymatou.iapi.sellerquery.parameter.resp.OrderInfoListResp;
import com.ymatou.iapi.sellerquery.parameter.resp.OrderItemInfoListResp;
import com.ymatou.query.trading.api.parameter.GetLatestPaidOrdersResponse;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;

import net.sf.json.JSONArray;
/**
*获取相关订单详情Call
*FreeMaker Template自动生成代码
*/
public class GetRelatedOrderInfosCall extends YmatouBaseCall{
	private static String opurl ="api/OrderQuery/GetRelatedOrderInfos";
	
	public GetRelatedOrderInfosCall() {
		super(EnvSetup.getSystemUrl("sellerquery_iapi"),opurl,"GET","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * @return
	 */
	public ArrayList<OrderInfoListResp> getResult() {
		ArrayList<OrderInfoListResp> result =new ArrayList<OrderInfoListResp>();
		try {
			String creditlist=new JSONObject(getString("data")).getString("orderInfoList");
			result = (ArrayList<OrderInfoListResp>) new Gson().fromJson(creditlist, new TypeToken<ArrayList<OrderInfoListResp>>() {}.getType());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	

	
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

}